package com.atguigu.gmall.item.rpc;

import com.atguigu.gmall.common.result.Result;

import com.atguigu.gmall.common.util.JsonUtil;
import com.atguigu.gmall.feign.product.ProductFeignClient;
import com.atguigu.gmall.item.service.SkuItemDetailService;
import com.atguigu.gmall.model.product.BaseCategoryView;
import com.atguigu.gmall.model.product.SkuInfo;
import com.atguigu.gmall.model.product.SpuSaleAttr;
import com.atguigu.gmall.model.product.SpuSaleAttrValue;
import com.atguigu.gmall.model.to.SkuDetailTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author A
 * @version 1.0
 * @description: TODO
 * @date 2024/9/11 4:37
 */
@RestController
@RequestMapping("/rpc/inner/item")
public class SkuItemDetailRpcController {

    @Autowired
    private SkuItemDetailService skuItemDetailService;
    @Qualifier("otherPool")
    @Autowired
    ThreadPoolExecutor poolExecutor;

    //商品详情服务
    //1.查分类
    //2.查sku信息
    //3.查价格
    //4.查所有销售属性集合
    //5.查实际sku组合
    //6.查介绍
    @GetMapping("/sku/detail/{skuId}")
    public SkuDetailTo getSkuDetail(@PathVariable("skuId") Long skuId) {
        poolExecutor.execute(()->{
            skuItemDetailService.increHotScore(skuId);
        });
        return skuItemDetailService.getSkuDetail(skuId);

    }
}
